var modelEditModule=angular.module('userEditApp', []);
modelEditModule.controller('userEditControl',  ['$scope', '$http',function($scope, $http) {
		var userId = angular.element($("#id")).val();  //获取id
		$scope.id=userId;
		$scope.getOrganiza = function(){
			$('#organiza').modal({remote: basePath+'/basicData/department/department_selList.jsp'})
		};

		
	     	 
	//取消修改，返回列表页面
	$scope.backLst = function() {
		location.href = basePath+'/system/sysUser/user_apply.jsp';
	};
	//保存
	$scope.EditModel = function() {
		var formValid = $scope.userForm.$valid;
		if (formValid) {
		   submitData();
		}
	};
		
	
	function submitData(){
	    var user = new Object();
	    user.userId = $scope.id;
		user.userAccount = $scope.userAccount;
		user.userName = $scope.userName;
		user.userEmail = $scope.userEmail;
		user.userPhone = $scope.userPhone;
		user.userTelephone = $scope.userTelephone;
		user.organizaName = angular.element($("#upname")).val();
		user.organizationId = angular.element($("#upcode")).val();
		user.userPassword = $scope.userPassword;
		user.userRemark = $scope.userRemark;
		var params ={'user': user};
		$http({
			url :  basePath+ '/sysUser/update',
			method:'post',
			params : params,
			}).success(function(data,header,config,status){
			   toastr.success("操作成功");
			   setTimeout(function() {
				   location.href = basePath+'/system/sysUser/user_apply.jsp';
			   }, 1000);
			}).error(function(data,header,config,status){
				toastr.success("操作失败");
				setTimeout(function() {
					location.href = basePath+'/system/sysUser/user_apply.jsp';
				}, 1000);
			});
	}
}]);
